From: Tim Deegan Date: Tue, 4 Jan 2011 11:32:20 +0000 (+0000) Subject: x86/mm: Add p2m_lock in set_shared_p2m_entry X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11004 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=b211f07fd598688eb18a8f84211c0d88fc2e8413;p=xen.git x86/mm: Add p2m_lock in set_shared_p2m_entry This avoids the immediate problem (calling set_p2m_entry() without the lock held) but leaves the underlying problem (no consistent locking order between page-sharing and p2m code) for later. Signed-off-by: Jui-Hao Chiang Signed-off-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 7815ab24fa..29dbbbf5fb 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2650,6 +2650,7 @@ int set_shared_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn) { int rc = 0; + int need_lock = !p2m_locked_by_me(p2m); p2m_type_t ot; mfn_t omfn; @@ -2665,7 +2666,11 @@ set_shared_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn) set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY); P2M_DEBUG("set shared %lx %lx\n", gfn, mfn_x(mfn)); + if ( need_lock ) + p2m_lock(p2m); rc = set_p2m_entry(p2m, gfn, mfn, 0, p2m_ram_shared); + if ( need_lock ) + p2m_unlock(p2m); if ( 0 == rc ) gdprintk(XENLOG_ERR, "set_mmio_p2m_entry: set_p2m_entry failed! mfn=%08lx\n",